﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BuffPrefixV2
{
    public class Prefix
    {
        public int ID { get; set; }
        public string PrefixName { get; set; }
        public List<int> BuffList { get; set; }
        public Prefix(int id,string name,List<int> buffs) {
            ID = id;
            PrefixName = name;
            BuffList = buffs;
        }
        /// <summary>
        /// 给称号添加Buff效果
        /// 同时对数据库进行更新
        /// </summary>
        /// <param name="buffID"></param>
        /// <returns></returns>
        public bool AddBuff(int buffID) {
            if (!BuffList.Contains(buffID))
            {
                BuffList.Add(buffID);
                DBManager.UpdatePrefix(this);
                return true;
            }
            else {
                return false;
            }
        }
        /// <summary>
        /// 删除称号的Buff效果
        /// 同时对数据库进行更新
        /// </summary>
        /// <param name="buffID"></param>
        /// <returns></returns>
        public bool DelBuff(int buffID)
        {
            if (!BuffList.Contains(buffID))
            {
                
                return false;
            }
            else
            {
                BuffList.Remove(buffID);
                DBManager.UpdatePrefix(this);
                return true;
            }
            
        }
        /// <summary>
        /// 设置称号的聊天颜色效果，支持 称号 玩家名字 聊天内容 的颜色进行修改
        /// 同时对数据库进行更新
        /// </summary>
        /// <param name="colorCode"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public string IntoString() {
            return string.Join(",",BuffList);
        }
        public enum SetType { 
        Prefix,
        Name,
        Text
        }
    }
}
